package cn.hsa.xxx.bookData.dto;

import cn.hsa.xxx.api.dto.InventoryBatchDTO;
import cn.hsa.xxx.bookData.entity.InventoryBatchDO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;


@Component
public class InventoryBatchDTOConverter {

    /**
     * Convert InventoryBatchDTO to InventoryBatchDO
     *
     * @param inventoryBatchDTO
     * @return
     */
    public InventoryBatchDO convertToInventoryBatchDO(InventoryBatchDTO inventoryBatchDTO) {
        if (inventoryBatchDTO == null) {
            return null;
        }
        InventoryBatchDO inventoryBatchDO = new InventoryBatchDO();

        //InventoryBatchDO.setId(InventoryBatchDTO.getId());
        //InventoryBatchDO.setName(InventoryBatchDTO.getName());
        //InventoryBatchDO.setSex(InventoryBatchDTO.getSex());
        //InventoryBatchDO.setAddr(InventoryBatchDTO.getAddr());

        //性能略差，但使用方便
        BeanUtils.copyProperties(inventoryBatchDTO, inventoryBatchDO);

        return inventoryBatchDO;
    }

    /**
     * Convert InventoryBatchDO to InventoryBatchDTO
     *
     * @param inventoryBatchDO
     * @return
     */
    public InventoryBatchDTO convertToInventoryBatchDTO(InventoryBatchDO inventoryBatchDO) {
        if (inventoryBatchDO == null) {
            return null;
        }

        InventoryBatchDTO inventoryBatchDTO = new InventoryBatchDTO();

        //InventoryBatchDTO.setId(InventoryBatchDO.getId());
        //InventoryBatchDTO.setName(InventoryBatchDO.getName());
        //InventoryBatchDTO.setSex(InventoryBatchDO.getSex());
        //InventoryBatchDTO.setAddr(InventoryBatchDO.getAddr());

        //性能略差，但使用方便
        BeanUtils.copyProperties(inventoryBatchDO, inventoryBatchDTO);

        return inventoryBatchDTO;
    }
}
